package com.niiwoo.civet.trade.report.upload.util;

import com.niiwoo.civet.trade.property.LycheePayProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Service;

import java.io.FileInputStream;
import java.util.Properties;

/**
 * 
 * @author wanglei02
 *
 */
@Slf4j
@Service
@EnableConfigurationProperties(LycheePayProperties.class)
public class ConfigUtil {
	/**
	 *
	 */
	public static String SERVERURL;
	/**
	 *
	 */
	public static String SIGNCERT;
	/**
	 *
	 */
	public static String USERNAME;
	/**
	 *
	 */
	public static String PASSWORD;
	
	/**
	 *
	 */
	public static String SUCCODE;
	
	static {
		try{
			Properties properties = new Properties();
			String basePath = ConfigUtil.class.getResource("/").getPath();
			properties.load(new FileInputStream(basePath+"/config.properties"));
			
			SERVERURL = properties.getProperty("rts.report.url");
			
			USERNAME = properties.getProperty("rts.login.username");
			
			PASSWORD = properties.getProperty("rts.login.password");
			
			SUCCODE = properties.getProperty("rts.succode");
			
			String signcertPath = properties.getProperty("rts.signcert.path");
			CertificateUtil certificateUtil = new CertificateUtil();
			SIGNCERT = certificateUtil.getSignCert(signcertPath);
			
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}
}
